home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / Media / fogpixshader.psh < prev    next >
Encoding:
Text File  |  2001-10-08  |  960 b   |  56 lines

  1. ps.1.1
  2.  
  3.  
  4. def c1, 1.0f,0.0f,0.0f,0.0f
  5. def c4, 0.0f,0.0f,1.0f,0.0f
  6. def c2, 1.0f,1.0f,1.0f,1.0f 
  7. def c3, 1.0f,1.0f,1.0f,1.0f
  8. def c0, 0.0f,0.0f,0.0f,0.0f
  9.  
  10. tex t0
  11. tex t1
  12. tex t2
  13.  
  14.  
  15. //t1 is far plane
  16. //t0 is near plane
  17. //input:
  18. //b    = low bits (a)  (4 bits) 
  19. //r   = high bits (b) (8 bits)
  20. //output: 
  21. //r1.b = (a1 - a2) (can't be greater than 7 bits set )
  22. //r1.r  = (b1 - b2)
  23. sub r1.rgb,t1,t0
  24. +sub_x4 r1.a,t0,t1
  25. mov_x4 r1.a,r1.a
  26. mad r1,t2,r1.a,r1
  27.  
  28. dp3 t0.rgba,r1,c4
  29.  
  30. //mov r1.a,r0.a
  31.  
  32.  
  33. //need to shift r1.rgb 6 bits
  34. //techinically, this will saturate
  35. //to 255 if any other bits are set, but thats fine
  36. //because in this case, the end result of the subtract 
  37. //would have to be saturated since we can't be subtracting
  38. //more than 127
  39. mov_x4 r1.rgb,r1
  40. dp3_x4 t1.rgba,r1,c1  //move into the alpha
  41.  
  42. //now add them together
  43. add_x2   r0.a,t0,t1 //the subtract was between 0-127,
  44. +mov r0.rgb,c3                 
  45.   
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.